package org.linlinjava.litemall.mechanismadmin.config;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.linlinjava.litemall.core.config.WxProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zhy
 * @date 2019-05-05 15:01
 **/
@Component
public class GetWxPayService {
	@Autowired
	private WxProperties wxPayProperties;

	public WxPayService getWxPay(){
		WxPayService wxPayServicesa;
		WxPayConfig payConfig = new WxPayConfig();
		payConfig.setAppId(StringUtils.trimToNull(wxPayProperties.getAppId()));
		payConfig.setMchId(StringUtils.trimToNull(wxPayProperties.getMchId()));
		payConfig.setMchKey(StringUtils.trimToNull(wxPayProperties.getMchKey()));
		payConfig.setKeyPath(StringUtils.trimToNull(wxPayProperties.getKeyPath()));
		payConfig.setNotifyUrl(StringUtils.trimToNull(wxPayProperties.getFiveNotifyUrl()));

		wxPayServicesa = new WxPayServiceImpl();
		wxPayServicesa.setConfig(payConfig);
		return wxPayServicesa;
	}

}
